<?php
require_once 'Zend/Application.php';

/**
 * Application class
 */
class Application extends Zend_Application
{
    /**
     * Application code. Used in database table names through BaseRow and BaseTable
     * @see BaseRow
     * @see BaseTable
     */
    const code = '';

    /**
     * Overrides the bootstrap() function to store the application object in the registry
     * @param null|string|array $resource
     * @return Application
     */
    public function bootstrap($resource = null)
    {
        Zend_Registry::set('Zend_Application', $this);
        return parent::bootstrap($resource);
    }

    /**
     * Return Zend Log object that was added in registry by Application_Resource_Log
     * @see Application_Resource_Log
     * @return Zend_Log
     */
    public static function getLogger()
    {
        return Zend_Registry::get('Zend_Log');
    }

    /**
     * Return version number loaded from config
     * @return string
     */
    public static function getVersion()
    {
        return Zend_Registry::get('Zend_Application')->getOption('version');
    }

    /**
     * Return the allowed locales
     * @return array
     */
    public static function getLocales()
    {
        return Zend_Registry::get('Zend_Application')->getOption('locale');
    }

    /**
     * @return boolean
     */
    public static function isUserAuthenticated()
    {
        $session = new Zend_Session_Namespace('session');
        return isset($session->authenticatedUser);
    }

    /**
     * @param bool $relative
     * @return string
     */
    public static function getCarouselPicturesPath($relative = false)
    {
        if ($relative) {
            return '/images/carousels/';
        }
        return realpath(dirname(__FILE__) . '/../htdocs/images/carousels/');
    }

    /**
     * @return bool
     */
    public static function isDevelopment()
    {
        return (getenv('ENVPHP') == 'loc');
    }
}